package com.yan.iftest;

import java.util.Scanner;

public class Test5 {
    public static void main(String[] args) {
        // 定义税前工资变量,税后工资变量
        double preWage;
        double afterWages;
        // 键盘输入税前工资
        Scanner input = new Scanner(System.in);
        System.out.println("输入税前工资");
        preWage = input.nextDouble();
        // 定义扣除三险一金后的工资变量
        double wage = preWage - (preWage * 0.1);
        // if嵌套求出税后工资
        if(wage <= 5000){
            // 不用交税的工资
            afterWages = wage;
            System.out.println("缴纳税额为:0" + "税后工资为:" + afterWages);
        }else {
            // 定义要交税金额变量
            double taxAmount = wage - 5000;
            // 定义缴纳税额
            double tax;
            // 0-3000元部分
           if(taxAmount > 0 && taxAmount <= 3000){
               tax = taxAmount * 0.03;
               afterWages = wage - taxAmount * 0.03;
               System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
           }
           // 3000-12000区间
            if(taxAmount > 3000 && taxAmount <= 12000){
                tax = 3000 * 0.03 + ((taxAmount - 3000) * 0.1);
                afterWages = wage - tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
            // 12000-25000区间
            if(taxAmount > 12000 && taxAmount <= 25000){
                tax = 3000 * 0.03 + 9000 * 0.1 + ((taxAmount - 12000) * 0.2);
                afterWages = wage - tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
            // 25000-35000区间
            if(taxAmount > 25000 && taxAmount <= 35000){
                tax = 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + ((taxAmount-25000) * 0.25);
                afterWages = wage -tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
            // 35000-55000区间
            if(taxAmount > 35000 && taxAmount <= 55000){
                tax = 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 100000 * 0.25 +((taxAmount-35000) * 0.3);
                afterWages = wage - tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
            // 55000-80000区间
            if(taxAmount > 55000 && taxAmount <= 80000){
                tax = 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 100000 * 0.25 + 200000 * 0.3 +((taxAmount - 55000) * 0.35);
                afterWages =wage -tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
            // 超过80000
            if (taxAmount >80000){
                tax = 3000 * 0.03 + 9000 * 0.1 + 13000 * 0.2 + 100000 * 0.25 + 200000 * 0.3 + 25000 * 0.35 + ((taxAmount - 800000) * 0.45);
                afterWages = wage - tax;
                System.out.println("缴纳税额为:" + tax + "税后工资为:" + afterWages);
            }
        }
    }
}
